package com.tbit.uqbike.client.service.impl;

import com.tbit.uqbike.client.dao.core.UserAccountLogDao;
import com.tbit.uqbike.client.pojo.UserAccountLog;
import com.tbit.uqbike.client.service.UserAccountLogService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Service("userAccountLogService")
public class UserAccountLogServiceImpl implements UserAccountLogService {
    @Autowired
    private UserAccountLogDao userAccountLogDao;

    @Override
    public List<UserAccountLog> getByUserId(Integer userId) {
        return userAccountLogDao.getByUserId(userId);
    }

    @Override
    public Integer queryCount(Integer accountId, Integer userId, Integer type) {
        Map<String, Object> params = new HashMap<String, Object>();
        params.put("accountId", accountId);
        params.put("userId", userId);

        return userAccountLogDao.queryCount(params);
    }

    @Override
    public List<UserAccountLog> queryPage(Integer accountId, Integer userId, Integer type, Integer rowCount, Integer pageNO) {
        Map<String, Object> params = new HashMap<String, Object>();
        params.put("accountId", accountId);
        params.put("userId", userId);
        params.put("start", (pageNO - 1) * rowCount);
        params.put("rowCount", rowCount);

        return userAccountLogDao.queryPage(params);
    }

    @Override
    public void insert(UserAccountLog userAccountLog) {
        userAccountLogDao.insert(userAccountLog);
    }


}  